package com.demo.function.shiro.service;

import com.demo.function.mybatis.mybatisplus.service.UserService;
import com.demo.model.entity.User;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import java.util.List;

@Service
public class ShiroService {

    @Resource
    private UserService userService;

    public User login(String username) {
        List<User> list = userService.lambdaQuery().eq(User::getUserName, username).list();
        Assert.isTrue(list.size() == 1, "用户不存在");
        return list.getFirst();
    }
}
